<?php
ob_start();
require_once '../sub/init.php';
require_once 'chkUadm.php';
if ( !strstr($session_crmkind,'adm') && !strstr($session_crmkind,'sq') && !strstr($session_crmkind,'sh')  && !CRM_ADM )exit(noauth('只有【管理员】【售前】【售后】角色才可以进入'));
require_once ZEAI.'m/div_left_so.php';
require_once ZEAI.'cache/udata.php';
require_once ZEAI.'cache/config_crm.php';
switch ($submitok) {
	case"utext":
		if (!ifint($uid))json_exit(array('flag'=>0,'msg'=>'亲，用户不存在'));
		$C = get_udata_text($uid);
		if(!empty($C)){
			json_exit(array('flag'=>1,'C'=>$C));
		}else{
			json_exit(array('flag'=>0,'msg'=>'用户不存在'));
		}
	break;
}
/****************************************SQL 开始*****************************************/
//因为包含全站查询// AND admid>0
$SQL = " kind<>4 AND (flag=1 OR flag=-2) ";

//会员库初始化
if($ifgh==1){
	$SQL .= " AND admid=0 ".getAgentSQL('aloneArea');
}else{
	if(!CRM_ADM)$hyk = (ifint($hyk,'1-3','1'))?$hyk:1;
	if($hyk!=3)$SQL .= " AND admid>0 ";
	
	//超管可以按门店搜索
	if(ifint($agentid) && CRM_ADM)$SQL .= " AND agentid=$agentid";
}

switch ($s) {
	case 'ext':
		$Skey  = trimhtml($Skey);
		$Skey2 = trimhtml($Skey2);
		if (!empty($Skey) || !empty($Skey2)){//按会员UID/昵称/姓名/手机
			if(ifmob($Skey)){
				$SQL .= " AND (mob='".$Skey."' OR mob2='".$Skey."') ";
			}elseif(ifint($Skey)){
				$SQL .= " AND id=".$Skey;
			}else{
				$SQL .= " AND (( truename LIKE '%".$Skey."%' ) OR ( crm_ubz LIKE '%".$Skey."%' ) OR ( uname LIKE '%".$Skey."%' ) OR ( nickname LIKE '%".$Skey."%' ) OR ( nickname LIKE '%".urlencode($Skey)."%' )) ";
			}
			if(ifint($Skey2))$SQL .= " AND admid=".$Skey2;
		}else{
			//线下线下均可
			switch ($kind) {
				case 1:$SQL .= " AND kind=1 ";break;
				case 2:$SQL .= " AND kind=2 ";break;
				case 3:$SQL .= " AND kind=3 ";break;
			}
			//会员库
			switch ($hyk) {
				case 1:$SQL .= " AND (admid=".$session_uid." OR hnid=".$session_uid." OR hnid2=".$session_uid.") ".getAgentSQL();break;//我的会员库
				case 2:$SQL .= getAgentSQL();break;//非超管匹配自己门店
				case 3:$SQL .= '';break;
			}
			//CRM按客户分类
			if(ifint($crm_ukind))$SQL .= " AND crm_ukind=$crm_ukind";
			//线上客户等级
			if(ifint($g))$SQL .= " AND grade=$g";
			//线下客户等级
			if(ifint($crm_ugrade))$SQL .= " AND crm_ugrade=$crm_ugrade";
			//线索来源
			if (ifint($crm_fromclue))$SQL .= " AND crm_fromclue=$crm_fromclue ";
			//
			$sex=trimhtml(dataIO($sex,'out'));if(!empty($sex))$SQL .= doinsql('sex',$sex);
			$photo_s=intval($photo_s);if ($photo_s == 1)$SQL .= " AND photo_s<>''";
			$areaid=trimhtml(dataIO($areaid,'out'));
			$area2id=trimhtml(dataIO($area2id,'out'));
			$areaid=getareaSQL($areaid);
			$area2id=getareaSQL($area2id);
			if(!empty($areaid))$SQL .= " AND areaid LIKE '%".$areaid."%' ";
			if(!empty($area2id))$SQL .= " AND area2id LIKE '%".$area2id."%' ";
			//age
			$age=trimhtml(dataIO($age,'out'));
			if(!empty($age)){
				$V=explode(',',$age);
				$V1=intval($V[0]);$V2=intval($V[1]);
				if(ifint($V1))$SQL .= " AND ( (YEAR(CURDATE())-YEAR(birthday)-(RIGHT(CURDATE(),5)<RIGHT(birthday,5))) >= '$V1' ) ";
				if(ifint($V2))$SQL .= " AND ( (YEAR(CURDATE())-YEAR(birthday)-(RIGHT(CURDATE(),5)<RIGHT(birthday,5))) <= '$V2' ) ";
			}
			//heigh
			$heigh=trimhtml(dataIO($heigh,'out'));
			if(!empty($heigh)){
				$V=explode(',',$heigh);$V1=intval($V[0]);$V2=intval($V[1]);
				if (ifint($V1))$SQL .= " AND ( heigh >= '$V1' ) ";
				if (ifint($V2))$SQL .= " AND ( heigh <= '$V2' ) ";
			}
			//weigh
			$weigh=trimhtml(dataIO($weigh,'out'));
			if(!empty($weigh)){
				$V=explode(',',$weigh);$V1=intval($V[0]);$V2=intval($V[1]);
				if (ifint($V1))$SQL .= " AND ( weigh >= '$V1' ) ";
				if (ifint($V2))$SQL .= " AND ( weigh <= '$V2' ) ";
			}
			//edu
			$edu=intval($edu);if(!empty($edu))$SQL .= " AND ( edu >= '$edu' ) ";
			//pay
			$pay=intval($pay);if(!empty($pay))$SQL .= " AND ( pay >= '$pay' ) ";
			//job
			$job=trimhtml(dataIO($job,'out'));if(!empty($job))$SQL .= doinsql('job',$job);
			//love
			$love=trimhtml(dataIO($love,'out'));if(!empty($love))$SQL .= doinsql('love',$love);
			//child
			$child=trimhtml(dataIO($child,'out'));if(!empty($child))$SQL .= doinsql('child',$child);
			//house
			$house=trimhtml(dataIO($house,'out'));if(!empty($house))$SQL .= doinsql('house',$house);
			//nation
			$nation=trimhtml(dataIO($nation,'out'));if(!empty($nation))$SQL .= doinsql('nation',$nation);
			//car
			$car=trimhtml(dataIO($car,'out'));if(!empty($car))$SQL .= doinsql('car',$car);
			//marrytime
			$marrytime=trimhtml(dataIO($marrytime,'out'));if(ifint($marrytime))$SQL .= " AND marrytime='$marrytime' ";
		}
	break;
	default://按择偶要求
		if(!CRM_ADM && $ifgh!=1)$SQL .= " AND (admid=".$session_uid." OR hnid=".$session_uid." OR hnid2=".$session_uid.") ".getAgentSQL();break;//我的会员库
	break;
}
//按售前售后
if($t=='sq'){
	$SQL_SQ_SH = "  AND admid>0 AND crm_ugrade=0";
}elseif($t=='sh'){
	$SQL_SQ_SH = "  AND admid>0 AND crm_ugrade>0";
}
$t1SQL = "  AND admid>0 AND crm_ugrade=0";
$t2SQL = "  AND admid>0 AND crm_ugrade>0";

$sortSQL  = " ORDER BY id DESC ";

if($ifgh!=1){
	//$MATCHSQL = ",(SELECT COUNT(*) FROM ".__TBL_CRM_MATCH__." WHERE uid=U.id) AS matchnum";
	$BBSSQL   = ",(SELECT COUNT(*) FROM ".__TBL_CRM_BBS__." WHERE uid=U.id) AS bbsnum";
	$QXSQL    = ",(SELECT COUNT(*) FROM ".__TBL_QIANXIAN__." WHERE senduid=U.id) AS qxnum";
	//
	$t0=$db->COUNT(__TBL_USER__,$SQL);
	$t1=$db->COUNT(__TBL_USER__,$SQL.$t1SQL);
	$t2=$db->COUNT(__TBL_USER__,$SQL.$t2SQL);
}
/*************************************  SQL结束 ********************************************/
$t=trimhtml($t);
$nav='index';?>
<!doctype html><html><head><meta charset="utf-8">
<title><?php echo $_ADM['admSiteName']; ?></title>
<?php echo HEADMETA; ?>
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<!--ext-->
<script src="<?php echo HOST;?>/cache/udata.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo HOST;?>/cache/areadata.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/zeai_div_area.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="js/m_qianxian_select.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>zeai_ios_select/separate/select.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<!--ext end-->
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<?php require_once 'm_style.php';?>
<link href="css/m_adm.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<style>
.ZEAI_list{padding:100px 0 80px;width:92%;margin:0 auto}
.ZEAI_list dl{width:100%;margin:0 auto 20px auto;border-radius:8px;background-color:#fff;box-shadow:0 0 28px rgb(0 0 0 / 8%);position:relative;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;position:relative;<?php if ($ifgh==1){?>padding-bottom:20px<?php }?>}
.ZEAI_list dl .tbody{padding:0 10px;margin:0 auto 10px auto;line-height:40px;color:#999;border-bottom:#f5f5f5 1px solid;text-align:left}
.ZEAI_list dl .tbody b,.ZEAI_list dl .tbody font{display:inline-block;color:#000;font-weight:normal;vertical-align:middle}
.ZEAI_list dl .tbody font{color:#999}
.ZEAI_list dl .tbody .vip_title{float:right;line-height:44px;position:relative}
.ZEAI_list dl .tbody .vip_title a{border:0}
.tip_top{min-width:60px;line-height:24px;font-size:12px;text-align:center;border-radius:12px;position:relative}
.tip_top:after{content:'';position:absolute;left:-webkit-calc(50% - 5px);bottom:17px;transform:rotate(45deg);width:0;height:0;border-top:10px solid transparent;border-right:10px solid transparent;border-top:10px solid #eee;}
.tip_top{position:absolute;right:-webkit-calc(50% - 30px);top:40px}

.ZEAI_list dl dt,.ZEAI_list dl dd{float:left;display:block}
.ZEAI_list dl dt{width:60px;padding-left:10px;text-align:left;line-height:150%;}
.ZEAI_list dl dt img.photo_s{width:40px;height:40px;object-fit:cover;-webkit-object-fit:cover;border-radius:50%}
.ZEAI_list dl dt .myinfobfb{left:10px;top:85px}
.ZEAI_list dl dt .user_kind{left:10px;top:105px;position:absolute;color:#999;width:40px;text-align:center}
.ZEAI_list dl dt .user_kind font.kind1{color:<?php echo $_ADM['color'];?>}
.ZEAI_list dl dt .user_kind font.kind2{color:#999}
.ZEAI_list dl dt .user_kind font.kind3{color:#009688}

.ZEAI_list dl dd{width:-webkit-calc(100% - 90px);text-align:left;line-height:150%;min-height:80px}
.ZEAI_list dl dd h5{font-size:13px;line-height:180%}
.ZEAI_list dl dd h5 b{color:#ccc;font-weight:normal}
.ZEAI_list dl dd h5 .btn{position:absolute;right:10px;top:60px}
.ZEAI_list dl .flag_ico,.ZEAI_list dl .crm_flag3_ico,img.u_public{position:absolute}
.ZEAI_list dl .flag_ico{right:23px;top:108px;width:40px;height:40px}
.ZEAI_list dl .crm_flag3_ico{right:19px;top:65px;width:50px;height:50px}
img.u_public{right:120px;top:50px;width:50px;height:50px}

.throwtimeT{color:<?php echo $_ADM['color'];?>;margin-left:5px}
.throwtime{font-size:12px;display:inline-block;min-width:150px;margin:5px;padding:5px;border-radius:3px;background-color:rgba(<?php echo c16_rgb($_ADM['color']);?>,.08)}

.ZEAI_list dl .datali{margin-top:5px;padding:0 10px;text-align:left;position:relative}
/*u2data*/
.u2data{text-align:left;padding:0 15px}
.u2data .dt{line-height:24px;height:24px;color:<?php echo $_ADM['color'];?>}
.u2data .dt i{width:26px;height:26px;line-height:24px;border-radius:16px;text-align:center;margin-right:8px;font-size:16px;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box}
.u2data .dt span{color:#999;font-weight:normal;float:right;margin-top:3px;margin-right:3px}
.u2data .dd{margin-left:12px;padding:5px 0 5px 14px}
.u2data .dd.zoyq{line-height:200%;padding-left:20px}
.u2data .dd.zoyq font{color:#999}
.u2data .dt i{border:rgba(<?php echo c16_rgb($_ADM['color']);?>,.15) 1px solid;color:rgba(<?php echo c16_rgb($_ADM['color']);?>,.3);}
.u2data .dd{border-left:rgba(<?php echo c16_rgb($_ADM['color']);?>,.1) 1px solid;}
.u2data .dd span{display:inline-block;padding:5px;margin:5px 4px;border-radius:3px;box-shadow:0 0 4px rgb(0 0 0 / 9%);max-width:94%;word-wrap:break-word;}
.u2data .dd b{color:#ccc;font-weight:normal;margin:0 10px}
.u2data .dd span font{color:#999}
.u2data .dd span img{width:40px;height:40px;display:block;margin:0 auto;border-radius:4px}

.ZEAI_list dl .ubtnbox{line-height:50px;height:50px;text-align:right;margin-top:15px}
.ZEAI_list dl .ubtnbox .btn{margin:5px 10px 0 0;padding:0 8px}
.ZEAI_list dl .ubtnbox a:first-child{margin-left:10px}
</style>
<!--ifrmae up-->
<?php require_once ZEAI.'cache/config_up.php';?>
<script>var up2='<?php echo UP;?>',upMaxMB=<?php echo $_UP['upMaxMB']; ?>,maxnum=5,browser='<?php echo browser();?>',uid='',upurl='';
</script>
<script src="<?php echo RES;?>m/js/ZeaiUP.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<?php
if (is_weixin()){
	require_once ZEAI."api/weixin/jssdk.php";?>
	<script src="<?php echo RES;?>jweixin-1.2.0.js"></script>
	<script>
	wx.config({debug: false,
		appId: '<?php echo $signPackage["appId"];?>',
		timestamp: <?php echo $signPackage["timestamp"];?>,
		nonceStr: '<?php echo $signPackage["nonceStr"];?>',
		signature: '<?php echo $signPackage["signature"];?>',
		jsApiList: ['chooseImage','uploadImage','previewImage','hideMenuItems']
	});
	</script>
<?php }?>
<!--ifrmae up end-->
</head>
<body>
<?php
$searchA = "&ifgh=$ifgh&hyk=$hyk&kind=$kind&crm_ukind=$crm_ukind&g=$g&crm_ugrade=$crm_ugrade&sex=$sex&photo_s=$photo_s&age=$age&heigh=$heigh&weigh=$weigh&areaid=$areaid&areatitle=$areatitle&area2id=$area2id&area2title=$area2title&job=$job&house=$house&car=$car&nation=$nation&love=$love&child=$child&edu=$edu&pay=$pay&marrytime=$marrytime&s=$s&Skey=$Skey&Skey2=$Skey2";
$mini_title=($ifgh==1)?'公海资源':'客户管理';
$mini_class='top_mini4 ';
$mini_L = '<em onClick="zeai.openurl(\'m_crm.php\')"><i class="ico" >&#xeaca;</i><span></span></em>';
require_once ZEAI.'m/top_mini.php';?>
<a class="so" id="user_search"><i class="ico">&#xe66c;</i><span>筛选</span></a>
<?php
$ifnoauth = false;
if ((strstr($session_crmkind,'adm') || CRM_ADM || strstr($session_crmkind,'sq') && strstr($session_crmkind,'sh')) && empty($ifgh)){
	$ifnoauth = true;?>
    <div class="tabmenu tabmenu3 tabmenufix">
        <a href="m_crm_user.php?t=<?php echo $searchA;?>"<?php echo (empty($t))?' class="ed"':'';?>>全部(<?php echo $t0;?>)</a>
        <a href="m_crm_user.php?t=sq<?php echo $searchA;?>"<?php echo ($t == 'sq')?' class="ed"':'';?>>售前(<?php echo $t1;?>)</a>
        <a href="m_crm_user.php?t=sh<?php echo $searchA;?>"<?php echo ($t == 'sh')?' class="ed"':'';?>>售后(<?php echo $t2;?>)</a>
    </div>
<?php }?>
<!--div_left_so-->
<div id="rangebox"></div>
<div class="div_left_so" id="user_so">
	<form action="<?php echo SELF;?>" method="get" name="www.yzlove.com" id="ZEAI_CN_FORM_ext">
    	<div class="form_uid">
        <input name="Skey" type="text" class="input" id="Skey" maxlength="20" value="<?php echo $Skey;?>" placeholder="客户UID/昵称/姓名/手机/备注" autocomplete="off">
        <button type="submit" class="ico">&#xe6c4;</button>
		</div>
        <?php if(empty($ifgh)){?>
            <div class="form_uid">
            <input name="Skey2" type="text" class="input" id="Skey2" maxlength="20" value="<?php echo $Skey2;?>" placeholder="认领红娘ID" autocomplete="off">
            <button type="submit" class="ico">&#xe6c4;</button>
            </div>
            <?php
		}
		$FT=json_decode(FT,true);
		if(empty($ifgh)){
			if(CRM_ADM){
				$rt2=$db->query("SELECT id,title FROM ".__TBL_CRM_AGENT__." WHERE flag=1 ORDER BY px DESC,id DESC");
				$total2 = $db->num_rows($rt2);
				if ($total2 > 0) {
					for($j=0;$j<$total2;$j++) {
						$rows2 = $db->fetch_array($rt2,'name');
						if(!$rows2)break;
						$agentARR[] = array('i'=>$rows2['id'],'v'=>$rows2['title']);
					}
					div_left_so_out(array('tbody'=>'所属门店','t'=>'agentid','tv'=>$agentid,'subkind'=>2,'newarr'=>json_decode(encode_json($agentARR)),'show'=>'off','ulcls'=>' col3'));
				}
			}
			div_left_so_out(array('tbody'=>'筛选范围','t'=>'hyk','tv'=>$hyk,'subkind'=>2,'bx'=>1,'newarr'=>json_decode('[{"i":"3","v":"总库"},{"i":"1","v":"我的客户"},{"i":"2","v":"我的门店"}]'),'ulcls'=>' col3'));//会员库
			div_left_so_out(array('tbody'=>'会员类型','t'=>'kind','tv'=>$kind,'subkind'=>2,'newarr'=>json_decode('[{"i":"1","v":"线上"},{"i":"2","v":"线下"},{"i":"3","v":"均可"}]'),'show'=>'off','ulcls'=>' col3'));//会员类型
		}
		
		div_left_so_out(array('tbody'=>'客户分类','t'=>'crm_ukind','tv'=>$crm_ukind,'subkind'=>2,'newarr'=>json_decode($_UDATA['crm_ukind']),'show'=>'off','ulcls'=>' col3'));
		//
		$uroleStr = str_replace("g","i",$_ZEAI['urole']);
		$uroleStr = str_replace("t","v",$uroleStr);
		div_left_so_out(array('tbody'=>'线上用户等级','t'=>'g','tv'=>$g,'subkind'=>2,'newarr'=>json_decode($uroleStr),'show'=>'off','ulcls'=>' col2'));
		//
		if( strstr($session_crmkind,'sh') || CRM_ADM ){
			if(empty($ifgh))div_left_so_out(array('tbody'=>'线下客户等级','t'=>'crm_ugrade','tv'=>$crm_ugrade,'subkind'=>2,'newarr'=>json_decode($_UDATA['crm_ugrade']),'show'=>'off','ulcls'=>' col2'));
		}
		div_left_so_out(array('tbody'=>$FT['sex']['t'],'t'=>'sex','tv'=>$sex,'subkind'=>3,'newarr'=>json_decode($_UDATA['sex']),'ulcls'=>' col3'));//性别
        div_left_so_out(array('tbody'=>$FT['photo_s']['t'],'t'=>'photo_s','tv'=>$photo_s,'subkind'=>2,'newarr'=>json_decode('[{"i":"1","v":"有头像"}]'),'ulcls'=>' col3'));//头像
		//默认值
		function range_str($F,$V) {
			if(empty($V))return '';
			global $_UDATA;
			$FARR=explode(',',$V);
			$F1=$FARR[0];$F2=$FARR[1];
			$F_UDATA=json_decode($_UDATA[$V],true);
			$F_str = mateset_out($F1,$F2,$F_UDATA['dw']);
			$F_str = str_replace("不限","",$F_str);
			return $F_str;
		}
        ?>
        <div class="listbox"><dl id="age" data="<?php echo (empty($age))?'23,24':$age;?>" class="rang"><dt>年龄范围</dt><dd><span><?php echo range_str('age',$age);?></span></dd></dl></div>
        <input type="hidden" id="form_age" name="age" value="<?php echo $age;?>">
        <div class="listbox"><dl id="heigh" data="<?php echo (empty($heigh))?'160,175':$heigh;?>" class="rang"><dt>身高范围</dt><dd><span><?php echo range_str('heigh',$heigh);?></span></dd></dl></div>
        <input type="hidden" id="form_heigh" name="heigh" value="<?php echo $heigh;?>">
        <div class="listbox"><dl id="weigh" data="<?php echo (empty($weigh))?'50,70':$weigh;?>" class="rang"><dt>体重范围</dt><dd><span><?php echo range_str('weigh',$weigh);?></span></dd></dl></div>
        <input type="hidden" id="form_weigh" name="weigh" value="<?php echo $weigh;?>">
        <!--地区-->
        <!--gz-->
        <div id="areabox" class="areabox"><div class="ul"><li><dl><dd></dd></dl></li></div></div>
        <input type="hidden" id="form_areaid" name="areaid" value="<?php echo $areaid;?>">
        <input type="hidden" id="form_areatitle" name="areatitle" value="<?php echo $areatitle;?>">
        <div class="listbox">
            <dl id="areaid" data="<?php echo $areaid;?>"><dt>工作地</dt><dd><span id="areatitle"><?php echo $areatitle;?></span></dd></dl>
        </div>
        <!--hj-->
        <div id="areabox2" class="areabox"><div class="ul"><li><dl><dd></dd></dl></li></div></div>
        <input type="hidden" id="form_area2id" name="area2id" value="<?php echo $area2id;?>">
        <input type="hidden" id="form_area2title" name="area2title" value="<?php echo $area2title;?>">
        <div class="listbox">
            <dl id="area2id" data="<?php echo $area2id;?>"><dt>户籍地</dt><dd><span id="area2title"><?php echo $area2title;?></span></dd></dl>
        </div>
        <!--地区结束-->
        <?php
        div_left_so_out(array('tbody'=>$FT['job']['t'],'t'=>'job','tv'=>$job,'subkind'=>3,'newarr'=>json_decode($_UDATA['job']),'ulcls'=>' col3','show'=>'off'));//职业
        div_left_so_out(array('tbody'=>$FT['house']['t'],'t'=>'house','tv'=>$house,'subkind'=>3,'newarr'=>json_decode($_UDATA['house']),'ulcls'=>' col2','show'=>'off'));//房
        div_left_so_out(array('tbody'=>$FT['car']['t'],'t'=>'car','tv'=>$car,'subkind'=>3,'newarr'=>json_decode($_UDATA['car']),'ulcls'=>' col2','show'=>'off'));//车
        div_left_so_out(array('tbody'=>$FT['nation']['t'],'t'=>'nation','tv'=>$nation,'subkind'=>3,'newarr'=>json_decode($_UDATA['nation']),'ulcls'=>' col3','show'=>'off'));//民族
        div_left_so_out(array('tbody'=>$FT['love']['t'],'t'=>'love','tv'=>$love,'subkind'=>3,'newarr'=>json_decode($_UDATA['love']),'ulcls'=>' col3','show'=>'off'));//婚况
        div_left_so_out(array('tbody'=>$FT['child']['t'],'t'=>'child','tv'=>$child,'subkind'=>3,'newarr'=>json_decode($_UDATA['child']),'ulcls'=>' col3','show'=>'off'));//小孩
        div_left_so_out(array('tbody'=>'最低'.$FT['edu']['t'],'t'=>'edu','tv'=>$edu,'subkind'=>2,'newarr'=>json_decode($_UDATA['edu']),'ulcls'=>' col3','show'=>'off'));//学历
        div_left_so_out(array('tbody'=>'最低'.$FT['pay']['t'],'t'=>'pay','tv'=>$pay,'subkind'=>2,'newarr'=>json_decode($_UDATA['pay']),'ulcls'=>' col3','show'=>'off'));//收入
        div_left_so_out(array('tbody'=>$FT['marrytime']['t'],'t'=>'marrytime','tv'=>$marrytime,'subkind'=>2,'newarr'=>json_decode($_UDATA['marrytime']),'ulcls'=>' col3','show'=>'off'));//结婚时间	
        ?>
        <script>div_left_so_init('user_so')</script>
        <div class="savebox"><button type="button" class="btn size3 reset" onClick="div_left_so_reset('user_so',['t','s','b','uid','ifgh'])">重置</button><button type="submit" class="btn size3 zeaibg ico">&#xe6c4; 确定</button></div>
        <input type="hidden" name="s" value="ext">
        <input type="hidden" name="t" id="t" value="<?php echo $t;?>" />
        <input type="hidden" name="ifgh" id="ifgh" value="<?php echo $ifgh;?>" />
    </form>
</div>
<!--div_left_so end-->
<form id="www_zeai_cn_FORM" class="ZEAI_list" method="get" action="<?php echo SELF; ?>"<?php echo (!$ifnoauth || $ifgh==1)?' style="padding-top:70px"':'';?>>
	<?php
	//$fields  = ",birthday,heigh,weigh,edu,pay,job,love,child,house,car,areatitle,area2title,smoking,drink,marrytype,marrytime,companykind,weixin,qq,mob,mob2,weixin_pic";
	//$fields .= ",mate_age1,mate_age2,mate_heigh1,mate_heigh2,mate_weigh1,mate_weigh2,mate_pay,mate_edu,mate_love,mate_car,mate_house,mate_areaid,mate_areatitle,mate_job,mate_child,mate_marrytime,mate_companykind,mate_smoking,mate_drink,mate_areaid2,mate_areatitle2,mate_other";没加文本复制之前
$fields  = ",marrytype,weixin,qq,mob,mob2,weixin_pic";
$fields .= ",sex,birthday,areatitle,area2title,love,child,heigh,weigh,edu,pay,house,car,blood,pay,blood,job,marrytime,companykind,smoking,drink,marrytime,aboutus";
$fields .= ",mate_age1,mate_age2,mate_heigh1,mate_heigh2,mate_weigh1,mate_weigh2,mate_pay,mate_edu,mate_love,mate_car,mate_house,mate_areaid,mate_areatitle,mate_job,mate_child,mate_marrytime,mate_companykind,mate_smoking,mate_drink,mate_areaid2,mate_areatitle2,mate_other";
	
	$rt = $db->query("SELECT id,agenttitle,kind,agentid,admid,admtime,admname,hnid,hnname,hnid2,hnname2,nickname,if2,sjtime,truename,photo_s,photo_f,sex,grade,flag,crm_ubz,myinfobfb,crm_ugrade,crm_ukind,crm_usjtime1,crm_usjtime2,regtime,endtime,flag,crm_flag,seatime,crm_usjtime1,crm_usjtime2,tguid,crm_ubz,RZ".$fields.$MATCHSQL.$BBSSQL.$QXSQL." FROM ".__TBL_USER__." U WHERE ".$SQL.$SQL_SQ_SH.$sortSQL." LIMIT ".$_ADM['admLimit']);
	$total = $db->num_rows($rt);
	if ($total <= 0 ) {
		echo "<div class='nodataico'><i class='ico'>&#xe608;</i>暂无信息<br><br><a class='aBAI' href='javascript:history.back(-1)'>返回上一步</a></div>";
	} else {
		$page_skin=2;$pagemode='mob';$pagesize=9;require_once ZEAI.'sub/page.php';
		for($i=1;$i<=$pagesize;$i++) {
			$rows = $db->fetch_array($rt,'name');if(!$rows) break;
			$id = $rows['id'];$uid = $id ;
			$nickname = trimhtml(dataIO($rows['nickname'],'out'));
			$truename = trimhtml(dataIO($rows['truename'],'out'));
			$nickname = str_replace($Skey,"<b class='Cf00'>".$Skey."</b>",$nickname);
			$truename = str_replace($Skey,"<b class='Cf00'>".$Skey."</b>",$truename);
			$sex      = $rows['sex'];
			$grade    = $rows['grade'];
			$photo_s  = $rows['photo_s'];
			$photo_f  = $rows['photo_f'];
			$birthday = $rows['birthday'];
			$regtime  = YmdHis($rows['regtime'],'Ymd');
			$flag = $rows['flag'];
			$myinfobfb = $rows['myinfobfb'];
			//
			$weixin     = trimhtml(dataIO($rows['weixin'],'out'));
			$qq         = trimhtml(dataIO($rows['qq'],'out'));
			$mob        = trimhtml(dataIO($rows['mob'],'out'));
			$mob2       = trimhtml(dataIO($rows['mob2'],'out'));
			$weixin_pic = $rows['weixin_pic'];
			//
			$kind  = intval($rows['kind']);
			$tguid = $rows['tguid'];
			$RZ    = $rows['RZ'];
			$areatitle  = $rows['areatitle'];
			$area2title = $rows['area2title'];
			//$rz_str = (!empty($RZ))?'认证：'.RZ_html($RZ,'s','color').'<b>|</b>':'';
			//$crm_fromclue= $rows['crm_fromclue'];
			$photo_s_url = (!empty($photo_s))?UP.smb($photo_s,'s'):RES.'photo_s'.$sex.'.png';
            $crm_usjtime1 = intval($rows['crm_usjtime1']);
            $crm_usjtime2 = intval($rows['crm_usjtime2']);
            $crm_ugrade = intval($rows['crm_ugrade']);
            $crm_ukind  = intval($rows['crm_ukind']);
            $crm_flag  = intval($rows['crm_flag']);
            $agentid   = intval($rows['agentid']);
            $admid     = intval($rows['admid']);
            $hnid      = intval($rows['hnid']);
            $hnid2     = intval($rows['hnid2']);
            $admtime   = intval($rows['admtime']);
            $admname   = dataIO($rows['admname'],'out');
            $hnname    = dataIO($rows['hnname'],'out');
            $hnname2   = dataIO($rows['hnname2'],'out');
            $agenttitle= dataIO($rows['agenttitle'],'out');
			$myinfobfb = $rows['myinfobfb'];
            $bbsnum   = intval($rows['bbsnum']);
            $qxnum    = intval($rows['qxnum']);
            $crm_ubz   = trimhtml(dataIO($rows['crm_ubz'],'out'));
			$truename   = (!empty($truename))?$truename.'・':'';
			$areatitle  = (empty($areatitle))?'':'<span>工作：'.$areatitle.'</span>';
			$area2title = (empty($area2title))?'':'<span>户籍：'.$area2title.'</span>';
			$heigh = (intval($rows['heigh'])>0)?'<span>'.udata('heigh',intval($rows['heigh'])).'</span>':'';
			$weigh = (intval($rows['weigh'])>0)?'<span>'.udata('weigh',intval($rows['weigh'])).'</span>':'';
			$birthday  = (!empty($rows['birthday']) && $rows['birthday']!='0000-00-00')?'<span>'.$rows['birthday'].'</span>':'';
			$age   = (@getage($rows['birthday'])<=0)?'':'<span>'.@getage($rows['birthday']).'岁</span>';
			$edu   = (ifint($rows['edu']))?'<span>'.udata('edu',intval($rows['edu'])).'</span>':'';
			$pay   = (ifint($rows['pay']))?'<span>'.udata('pay',intval($rows['pay'])).'</span>':'';
			$job   = (ifint($rows['job']))?'<span>'.udata('job',intval($rows['job'])).'</span>':'';
			$love      = (ifint($rows['love']))?'<span>'.udata('love',intval($rows['love'])).'</span>':'';
			$marrytype = (!empty($rows['marrytype']))?'<span>'.udata('marrytype',$rows['marrytype']).'</span>':'';
			$child     = (ifint($rows['child']))?'<span>'.udata('child',intval($rows['child'])).'</span>':'';
			$house     = (ifint($rows['house']))?'<span>'.udata('house',intval($rows['house'])).'</span>':'';
			$car       = (ifint($rows['car']))?'<span>'.udata('car',intval($rows['car'])).'</span>':'';
			$companykind= (ifint($rows['companykind']))?'<span>'.udata('companykind',intval($rows['companykind'])).'</span>':'';
			$marrytime = (ifint($rows['marrytime']))?'<span>'.udata('marrytime',intval($rows['marrytime'])).'结婚'.'</span>':'';
			$smoking = (ifint($rows['smoking']))?'<span>'.udata('smoking',intval($rows['smoking'])).'</span>':'';
			$drink   = (ifint($rows['drink']))?'<span>'.udata('drink',intval($rows['drink'])).'</span>':'';
			//
			$weixin = (!empty($weixin))?'<span onclick="copylxff(\''.$weixin.'\',\'《微信》\');"><font>微信：</font>'.$weixin.'</span>':'';
			$qq     = (!empty($qq))?'<span onclick="copylxff(\''.$qq.'\',\'《QQ》\');"><font>QQ：</font>'.$qq.'</span>':'';
			$mob    = (!empty($mob))?'<span><font>手机：</font><a href="tel:'.$mob.'">'.$mob.'</a></span>':'';
			$mob2   = (!empty($mob2))?'<span><font>备用手机：</font><a href="tel:'.$mob2.'">'.$mob2.'</a></span>':'';
			$weixin_pic  = (!empty($weixin_pic))?'<span><img src="'.UP.$weixin_pic.'" onclick="ZeaiM.piczoom(\''.UP.$weixin_pic.'\');">微信二维码</span>':'';
			$contact_str = $weixin.$weixin_pic.$qq.$mob.$mob2;
			//
			if($flag == -2){
				$flag_str = '<img src="images/flag_2.png" width="60" height="60" class="flag_ico">';
			}else{
				$flag_str = '';
			}
			if($crm_ugrade>0){
				$crm_flag_str = ($crm_flag==3)?'<img src="images/crm_flag3.png" class="crm_flag3_ico">':'<div class="crm_flag3_ico">'.crm_flag_title($crm_flag).'</div>';
			}else{$crm_flag_str='';}
			if($myinfobfb >80){$myinfobfb_cls = ' myinfobfb2 ';}elseif($myinfobfb >20){$myinfobfb_cls = ' myinfobfb1';}else{$myinfobfb_cls = ' myinfobfb0';}
			$myinfobfb_str = '<span class="myinfobfb'.$myinfobfb_cls.'">'.$myinfobfb.'%</span>';
			$crm_vip_title = crm_ugrade_time($uid,$crm_ugrade,'noAno__',$crm_usjtime1,$crm_usjtime2);
			$ddiff = $crm_usjtime2-ADDTIME;
			if ($ddiff < 0){
				$tip_top = '<span class="Cf00">已过期</span>';
			} else {
				$tip_top = '还剩<span class="Cf00">'.intval($ddiff/86400).'</span>天';
			}
            $agenttitle = dataIO($rows['agenttitle'],'out');
            $agenttitle = (!empty($agenttitle))?'<font class="C999">门店：</font>'.$agenttitle.'<br>':'';
			$crm_ubz = (!empty($crm_ubz))?'<span>备注：'.$crm_ubz.'</span>':'';
			$shhy_str = $love.$child.$marrytype.$marrytime.$smoking.$drink;
			$jjzk_str = $companykind.$job.$pay.$house.$car;
			$mate_str = mate_echo($rows);
			$title2 = (!empty($nickname))?$uid.'<font>|</font>'.urlencode(trimhtml($nickname)):$uid;
			?>
            <dl id="tr<?php echo $id;?>">
            	<div class="tbody">
                	<input type="checkbox" name="list[]" value="<?php echo $id; ?>" uid="<?php echo $uid; ?>" id="id<?php echo $id; ?>" class="checkskin"><label for="id<?php echo $id; ?>" class="checkskin-label"><i class="i1"></i></label>
                	<?php echo uicon($sex.$grade);?><b><?php echo $uid;?></b><font>（<?php echo $truename.$nickname;?>）</font>
                    <div class="vip_title">
                    	<?php if (!empty($crm_vip_title)){?>
							<?php echo $crm_vip_title;?><div class="tip_top"><?php echo $tip_top;?></div>
                        <?php }?>
                    </div>
				</div>
                <dt>
                	<a href="<?php echo mHref('crm_u',$uid);?>"><img class="photo_s" src="<?php echo $photo_s_url;?>"></a>
                	<span class="myinfobfb<?php echo $myinfobfb_cls;?>"><?php echo $myinfobfb;?>%</span>
                    <span class="user_kind"><font class="kind<?php echo $kind;?>"><?php echo user_kind($rows['kind']); ?></font></span>
                </dt>
                <dd>
					<h5>
					<?php
					if (!empty($agenttitle) || !empty($admname) || !empty($admid) || !empty($hnname) || !empty($hnid) || !empty($hnname2) || !empty($hnid2)){
						echo $agenttitle;
						$adm_str = ($admtime>0)?'认领':'录入';
						if(!empty($admname) || !empty($admid)){echo '<font class="C999">'.$adm_str.'：</font>'.$admname.' <font class="C999">ID:'.$admid.'</font>';}
						if(!empty($hnname) || !empty($hnid)){echo '<br><font class="C999">售前：</font>'.$hnname.' <font class="C999">ID:'.$hnid.'</font>';if($crm_ugrade==0)echo sea_djs($seatime,'sq');}
						if(!empty($hnname2) || !empty($hnid2)){echo '<br><font class="C999">售后：</font>'.$hnname2.' <font class="C999">ID:'.$hnid2.'</font>';if($crm_ugrade>0)echo sea_djs($seatime,'sh');}
						if(ifint($tguid)){
							$tgrow = $db->ROW(__TBL_TG_USER__,"uname,nickname","id=".$tguid,"name");
							if ($tgrow){
								$uname_tg    = dataIO($tgrow['uname'],'out');
								$nickname_tg = dataIO($tgrow['nickname'],'out');
								$nickname_tg=(empty($nickname_tg))?$uname_tg:$nickname_tg;
								echo '<br><font class="C999">推荐人：</font>'.$nickname_tg.'<font class="C999">(ID:'.$tguid.')</font><br>';
							}
						}
					}else{
						$rt2=$db->query("SELECT agentid,agenttitle,admid,admname,throwtime FROM ".__TBL_CRM_CLAIM_LIST__." WHERE adddate='0000-00-00' AND uid=".$uid." ORDER BY id DESC");
						$total2 = $db->num_rows($rt2);
						if ($total2 > 0) {
							echo '<div class="throwtimeT">扔海历史</div>';
							for($i2=1;$i2<=$total2;$i2++) {
								$rows2 = $db->fetch_array($rt2,'name');
								if(!$rows2) break;
								$agentid2   = intval($rows2['agentid']);
								$agenttitle2= dataIO($rows2['agenttitle'],'out');
								$admid2     = intval($rows2['admid']);
								$admname2   = dataIO($rows2['admname'],'out');
								$throwtime2 = YmdHis($rows2['throwtime'],'YmdHis');
								$agenttitle2= (!empty($agenttitle2))?'《'.$agenttitle2.'》':'';
								$admname2   = (!empty($admname2))?$admname2.' <font class="C999">ID:'.$admid2.'</font><br>'.$throwtime2:'';
								echo '<div class="throwtime">'.$agenttitle2.$admname2.'</div>';
							}
						}
						$rs_style = ($crm_ugrade>0)?' style="top:100px"':'';
						echo '<img src="images/u_public.png" class="u_public">';
						echo '<a href="javascript:;" class="btn size2 zeaibg rl" uid="'.$uid.'"'.$rs_style.'>我要认领</a>';
					}?>
					</h5>
                </dd>
                <?php echo $flag_str.$crm_flag_str;?>
                <div class="clear"></div>
				<div class="datali u2data">
       				<div class="dt"><i class="ico">&#xe679;</i>基础资料<span><font>注册时间：</font><?php echo $regtime; ?></span></div>         
                	<div class="dd"><?php echo $birthday.$age.$heigh.$weigh.$edu.$areatitle.$area2title.$crm_ubz;?></div>
       				<?php if (!empty($shhy_str)){?><div class="dt"><i class="ico">&#xe62f;</i>生活婚姻</div><div class="dd"><?php echo $shhy_str;?></div><?php }?>     
                	<?php if (!empty($jjzk_str)){?><div class="dt"><i class="ico">&#xe61a;</i>经济状况</div><div class="dd"><?php echo $jjzk_str;?></div><?php }?>
                	<?php if (!empty($mate_str)){?><div class="dt"><i class="ico">&#xe65a;</i>择偶要求<span class="ico">&#xe60b; 展开</span></div><div class="dd zoyq" style="display:none"><?php echo $mate_str;?></div><?php }?>
                    <?php if (!empty($contact_str) && crm_ifcontact($agentid,$admid,$hnid,$hnid2)){?>
                    	<div class="clear"></div>
                        <div class="dd" style="height:5px;padding:0"></div>
						<div class="dt"><i class="ico">&#xe627;</i>联系方法<span class="ico">&#xe60b; 展开</span></div><div class="dd lxff" style="display:none"><?php echo $contact_str;?></div>
					<?php }?>
                </div>
                
                <?php if ($ifgh!=1){?>
                <div class="ubtnbox">
                    <a href="javascript:utext('<?php echo get_udata_text($rows);?>')" class="btn size2 BAI FL">文本卡</a>
                    <a href="<?php echo HOST;?>/m/my_card.php?uid=<?php echo $uid;?>" class="btn size2 BAI FL">相亲卡</a>
                    <a href="javascript:;" class="btn size2 BAI FL btn_numtips gjlist" photo_s_url=<?php echo $photo_s_url;?> uid="<?php echo $id;?>" title2="<?php echo $title2;?>">跟进<?php echo ($bbsnum>0)?'<span>'.$bbsnum.'</span>':'';?></a>
                    <a href="m_qianxian_select.php?uid=<?php echo $uid;?>&b=<?php echo $p;?>&t=<?php echo $t;?>" class="btn size2 BAI FL btn_numtips">牵线<?php echo ($qxnum>0)?'<span>'.$qxnum.'</span>':'';?></a>
                    <?php if(in_array('crm_user_mod',$QXARR) || in_array('u_mod',$QXARR) || CRM_ADM  ){?>
                    	<a href="m_u_mod.php?submitok=mod&uid=<?php echo $uid;?>&t=crm" class="btn size2 BAI umod FR ico">修改</a>
                    <?php }?>
                    <div class="clear"></div>
                </div>
                <?php }?>
                
            </dl>
			<?php
		}
	}
	?>
</form>
<script>var bg = '<?php echo $_Style['list_bg']; ?>',overbg   = '<?php echo $_Style['list_overbg']; ?>',selectbg = '<?php echo $_Style['list_selectbg']; ?>';</script>
<?php if ($total > 0 ){?>
    <?php echo $page_cls;?>
    <div class="listbottombox">
        <input type="checkbox" id="checkboxall2" class="checkskin checkboxall"><label for="checkboxall2" class="checkskin-label"><i class="i1"></i></label>&nbsp;&nbsp;
        <?php if($t=='sq' && CRMQX('crm_hn_utask_sq_add')){?><button type="button" id="btn_fp_sq" class="btn size2 zeaibg disabled action" onClick="crm_user_guohu({url:'crm_hn_utask_add.php?t=1&ulist=',browser:'mob',btnobj:this,title:'分配售前红娘',w:'auto',h:'auto'});">分配售前</button>&nbsp;<?php }?>
        <?php if($t=='sh' && CRMQX('crm_hn_utask_sh_add')){?><button type="button" id="btn_fp_sh" class="btn size2 zeaibg disabled action" onClick="crm_user_guohu({url:'crm_hn_utask_add.php?t=3&ulist=',browser:'mob',btnobj:this,title:'分配售后红娘',w:'auto',h:'auto'});">分配售后</button>&nbsp;<?php }?>
        <?php if(empty($t)){?>
        	<?php if(CRMQX('claim') && $ifgh==1){?><button type="button" id="btn_rl" class="btn size2 zeaibg disabled action">批量认领</button>&nbsp;&nbsp;<?php }?>
        	<?php if(CRMQX('crm_user_guohu') && $ifgh!=1){?><button type="button" id="btn_fp" class="btn size2 zeaibg disabled action" onClick="crm_user_guohu({url:'crm_user_guohu.php?submitok=mob&ulist=',browser:'mob',btnobj:this,title:'客户归属修改',w:'auto',h:'auto'});">归属修改</button><?php }?>
		<?php }?>
        <?php if ($total > $pagesize)echo '<div class="pagebox">'.$pagelist.'</div>'; ?>
    </div>
    <div id="backtop"><a id="btmTopBtn"><i class="ico">&#xe60c;</i>顶部</a></div>
    <script>
    document.body.onscroll = backtop_alone;
	//认领
	var addtips='<b class="S16">确定认领此用户么？</b><br>1．认领后此用户前台个人主页将展示您的二维码，其他用户联系此用户将会加您微信，将自动更新为您所在门店<br>2．红娘帐号“<b>网站显示</b>”功能开启后用户主页才会展示您二维码等信息<br>3．认领后请尽快跟进此用户并提供服务（将自动将您设为【售前红娘】无需主管分配）';
	zeai.listEach('.rl',function(obj){
		obj.onclick = function(){
			var id = parseInt(obj.getAttribute("uid"));
			zeai.confirm(addtips,function(){
				zeai.ajax({url:'crm_claim_public'+zeai.ajxext+'submitok=add_update&list[]='+id},function(e){
					rs=zeai.jsoneval(e);
					zeai.msg(0);zeai.msg(rs.msg,{time:3});
					if(rs.flag==1){setTimeout(function(){location.reload(true);},1000);}
				});
			});
		}
	});
	<?php if(empty($t) && $ifgh==1){?>
	o('btn_rl').onclick = function() {
		allList({
			btnobj:this,
			url:'crm_claim_public'+zeai.ajxext+'submitok=add_update',
			title:'批量认领',
			msg:'正在处理中...',
			ifjson:true,
			ifconfirm:true
		});	
	}
	<?php }?>
	zeai.listEach('.zoyq',function(obj){
		var objH = obj.offsetHeight;
			var c = obj.previousElementSibling;
			var span = zeai.tag(c,'span')[0];
			span.onclick = function(){obj.show();span.hide();}
	});
	zeai.listEach('.lxff',function(obj){
		var objH = obj.offsetHeight;
			var c = obj.previousElementSibling;
			var span = zeai.tag(c,'span')[0];
			span.onclick = function(){obj.show();span.hide();}
	});
	function copylxff(str,t){zeai.copy(str,function(){zeai.msg(t+'复制成功<br>您可以粘贴分享给好友啦');});}
	function utext(uid){
		zeai.copy(uid,function(){zeai.msg('《个人资料》复制成功<br>您可以粘贴分享给好友啦');})
		return false;
		zeai.ajax('m_crm_user'+zeai.ajxext+'submitok=utext&uid='+uid,function(e){var rs=zeai.jsoneval(e);
			if (rs.flag == 1){
				zeai.copy(rs.C,function(){zeai.msg('《个人资料》复制成功<br>您可以粘贴分享给好友啦');})
			}else{
				zeai.msg(rs.msg);	
			}
		});
	}
	zeai.listEach('.gjlist',function(obj){
		var uid = parseInt(obj.getAttribute("uid")),
		title2 = obj.getAttribute("title2");
		var photo_s_url = decodeURIComponent(obj.getAttribute("photo_s_url"));
		var photo_s_iframeL = (!zeai.empty(photo_s_url))?'<img src="'+photo_s_url+'" class="photo_s_iframeL">':'';
		obj.onclick=function(){
			ZeaiM.iframe({title:photo_s_iframeL+'<span>【'+title2+'】跟进管理</span>',url:'crm_gj_yj.php?uid='+uid+'&submitok=gj_list',fn:function(){
				setTimeout(function(){location.reload(true);},500);
			}});
		}
	});
    </script>
    <script src="js/zeai_tablelist.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<?php }?>
</body></html><?php ob_end_flush();?>